<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Append raw XML data</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.domdocumentfragment.html">DOMDocumentFragment</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.domdocumenttype.html">DOMDocumentType</a></div>
 <div class="up"><a href="class.domdocumentfragment.html">DOMDocumentFragment</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="domdocumentfragment.appendxml" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMDocumentFragment::appendXML</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">DOMDocumentFragment::appendXML</span> &mdash; <span class="dc-title">Append raw XML data</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domdocumentfragment.appendxml-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>DOMDocumentFragment::appendXML</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
   )</div>

  <p class="para rdfs-comment">
   Appends raw XML data to a DOMDocumentFragment. 
  </p>
  <p class="para">
   This method is not part of the DOM standard. It was created as a simpler
   approach for appending an XML DocumentFragment in a DOMDocument.
  </p>
  <p class="para">
   If you want to stick to the standards, you will have to create a temporary
   DOMDocument with a dummy root and then loop through the child nodes of the
   root of your XML data to append them. 
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domdocumentfragment.appendxml-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">data</code></em></dt>

     <dd>

      <p class="para">
       XML to append.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domdocumentfragment.appendxml-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-domdocumentfragment.appendxml-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5301">
    <p><strong>Example #1 Appending XML data to your document</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$doc&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #DD0000">"&lt;root/&gt;"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$f&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDocumentFragment</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$f</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendXML</span><span style="color: #007700">(</span><span style="color: #DD0000">"&lt;foo&gt;text&lt;/foo&gt;&lt;bar&gt;text2&lt;/bar&gt;"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">documentElement</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveXML</span><span style="color: #007700">();&nbsp;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;root&gt;&lt;foo&gt;text&lt;/foo&gt;&lt;bar&gt;text2&lt;/bar&gt;&lt;/root&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.domdocumentfragment.html">DOMDocumentFragment</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.domdocumenttype.html">DOMDocumentType</a></div>
 <div class="up"><a href="class.domdocumentfragment.html">DOMDocumentFragment</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
